<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        div{
            padding:10px;margin:10px;border:solid 1px black;
        }
    </style>
</head>
<body>
    <div class="app">

        <h1>正在学习 - {{title}}</h1>
        <h2>这是 - {{subTit}}</h2>

        <Hello></Hello>
        <HELLO></HELLO>

        <World></World>

    </div>
</body>
<script src="../vue.global.js"></script>
<template id="h">
    <div class="">
        <h3>这是 - {{title}}</h3>
        <Hello-child></Hello-child>
    </div>
</template>
<template id="w">
    <div class="">
        <h3>这是 - {{title}}</h3>
    </div>
</template>
<template id="c">
    <div class="">
        <h3>这是 - {{title}}</h3>
    </div>
</template>
<script>
    // 局部组件：谁注册，谁使用!

    // 根组件
    const app = Vue.createApp({
        data(){
            return {
                title:"局部组件",
                subTit:"根组件"
            }
        },
        components: {
            Hello: {
                data(){
                    return {
                        title:"hello组件"
                    }
                },
                template:`#h`,
                components: {
                    HelloChild:{
                        data(){
                            return {
                                title:"child组件"
                            }
                        },
                        template:`#c`,
                    }
                }
            },
            World:{
                data(){
                    return {
                        title:"world组件"
                    }
                },
                template:`#w`
            }
        }
    })



    // 挂载根组件
    app.mount(".app")


</script>
</html>